import React,{Component} from 'react';
import {
    ScrollView,
    View,
    Text,
    TextInput,
    TouchableOpacity,
    FlatList
} from 'react-native'
import StyCom from '../../../../components/Style';
import Tool from '../../../../components/Tool';
const Color  = StyCom.color;
const Font = StyCom.fontSize;
export default class Notice extends Component{
    constructor(props) {
        super(props);
       // this.sta
    }
    _saveNotice(){

    }
    _getCityOrg(){
        Tool.fetchJson(Tool.appPath.mkst + 'advertise/selectOrg','',function (data) {

        },function () {

        },function () {

        })
    }
    render(){
        const Dimensions = require('Dimensions');
        const width = Dimensions.get('window').width;
        return(
            <ScrollView style={[styles.contentView,{width:width}]}>
                <InputView filed={'title'} title={'公告标题'}/>
                <InputView filed={'content'} title={'公告内容'}/>
                <InputView filed={'abateTime'} title={'过期时间'}/>
                <Select filed={'city'} title={'地市可见'}/>
                <Button this={this}/>
            </ScrollView>
        )
    }
}
class Select extends Component{

    render(){
        return(
            <View style={{marginBottom:20}}>
                <Text style={styles.textView}>{this.props.title}</Text>
                <ScrollView>
                    <FlatList
                        data={[{cityName:'成都'},{cityName:'成都'},{cityName:'成都'},{cityName:'成都'},{cityName:'成都'},{cityName:'成都'},{cityName:'成都'},{cityName:'成都'},{cityName:'成都'}]}
                        renderItem={({item}) =>
                            <TouchableOpacity onPress={()=> _this._saveNotice()}>
                                <Text style={{color:Color.black,textAlign:'center'}}>{item.cityName}</Text>
                            </TouchableOpacity>
                        }
                    />
                </ScrollView>
            </View>
        )
    }
}
class Button extends Component{
    render(){
        let _this = this.props.this;
        return(
            <View style={styles.buttonView}>
                <TouchableOpacity onPress={()=> _this._saveNotice()}>
                    <Text style={{color:Color.white,textAlign:'center'}}>创建公告</Text>
                </TouchableOpacity>
            </View>
        )
    }
}
class InputView extends Component{
    render(){
        return(
            <View style={{marginBottom:20}}>
                <Text style={styles.textView}>{this.props.title}</Text>
                <TextInput
                    ref={''}
                    underlineColorAndroid='transparent'
                    style={styles.textInputView}
                   // onChangeText={(text) => form.setValue(name,text)}
                    //value={form[name]}
                    //secureTextEntry={secureTextEntry? true : false}
                  //  keyboardType={keyboardType ? 'numeric' : 'default'}
                />
            </View>
        )
    }
}
const styles = {
    buttonView:{
        backgroundColor:Color.blue,
        width:80,
        height:30,
        borderRadius:50,
        justifyContent:'center',
        //alignSelf:'flex-end',
    },
    contentView:{
        backgroundColor:StyCom.color.white,
        padding:40,
    },
    textView:{
        fontSize:StyCom.fontSize.normal,
        marginLeft:10,
    },
    textInputView: {
        marginTop: -10,
        marginLeft:10,
      //  height:50,
        borderBottomWidth:0.2,
        borderBottomColor:StyCom.color.gray,
        flexDirection: 'column',
        justifyContent: 'center',
    },
}